package net.vinote.smart.platform.module.dbpool;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * 数据源配置Bean
 * 
 * @author 郑俊伟
 * 
 */
class ConnectionParam {
	public static final String SYSTEM_CFG_DATABASE_NAME = "database.name";

	public static final String SYSTEM_CFG_DATABASE_DRIVER = "database.driver";

	public static final String SYSTEM_CFG_DATABASE_URL = "database.url";

	public static final String SYSTEM_CFG_DATABASE_USERNAME = "database.username";

	public static final String SYSTEM_CFG_DATABASE_PASSWORD = "database.password";

	public static final String SYSTEM_CFG_DATABASE_MINCONNECT = "database.minConnect";

	public static final String SYSTEM_CFG_DATABASE_MAXCONNECT = "database.maxConnect";

	public static final String SYSTEM_CFG_DATABASE_CONNECTTIMEOUT = "database.connectTimeout";

	public static final String SYSTEM_CFG_DATABASE_COMMIT = "database.commit";

	/** JDBC驱动 */
	private String dirver;
	private String url;
	private String user;
	private String password;
	/** 最小连接数 */
	private int minConnectNum;
	/** 最大连接数 */
	private int maxConnectNum;
	/** 连接超时时长 */
	private int connectTimeout;

	/** 是否自动提交 */
	private boolean autoCommit;

	public String getDirver() {
		return dirver;
	}

	public void setDirver(String dirver) {
		this.dirver = dirver;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getMinConnectNum() {
		return minConnectNum;
	}

	public void setMinConnectNum(int minConnectNum) {
		this.minConnectNum = minConnectNum;
	}

	public int getMaxConnectNum() {
		return maxConnectNum;
	}

	public void setMaxConnectNum(int maxConnectNum) {
		this.maxConnectNum = maxConnectNum;
	}

	public int getConnectTimeout() {
		return connectTimeout < 1000 ? 1000 : connectTimeout;
	}

	public void setConnectTimeout(int connectTimeout) {
		this.connectTimeout = connectTimeout;
	}

	public boolean isAutoCommit() {
		return autoCommit;
	}

	public void setAutoCommit(boolean autoCommit) {
		this.autoCommit = autoCommit;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
